package form.ui.component.Slider
{
	import flash.display.GradientType;
	
	import form.ui.core.ProgrammaticSkin;
	import form.utils.ColorUtil;

	public class SliderTrackSkin extends ProgrammaticSkin
	{
		public var borderColor:uint = 0xCCCCCC;
		public var fillAlphas:Array = [0.2, 0.6];
		public var trackColors:Array = [0xFFFFFF, 0xFFFFFF];
		
		override public function get measuredWidth():Number
		{
			return 200;
		}
	
		override public function get measuredHeight():Number
		{
			return 4;
		}
		
		public function SliderTrackSkin()
		{
			super();
		}
		
		override protected function updateDisplayList(w:Number, h:Number):void
		{	
			
			// User-defined styles.
			var borderColor:Number = this.borderColor;
			var fillAlphas:Array = this.fillAlphas;
			var fillColors:Array = this.trackColors;
			
			// Derivative styles.
			var borderColorDrk:Number =
				ColorUtil.adjustBrightness2(borderColor, -50);
			
			graphics.clear();
			
			drawRoundRect(0,0,w,h,0,0,0); // Draw a transparent rect to fill the entire space
			
			drawRoundRect(
				1, 0, w, h - 1, 1.5,
				borderColorDrk, 1, null,
				GradientType.LINEAR, null,
				{ x: 2, y: 1, w: w - 2, h: 1, r: 0 });
	
			drawRoundRect(
				2, 1, w - 2, h - 2, 1,
				borderColor, 1, null,
				GradientType.LINEAR, null,
				{ x: 2, y: 1, w: w - 2, h: 1, r: 0 });
			
			drawRoundRect(
				2, 1, w - 2, 1, 0,
				fillColors, Math.max(fillAlphas[1] - 0.3, 0),
				horizontalGradientMatrix(2, 1, w - 2, 1));
		}
	}
}